package ms.shop.dao;

import mapper.MsMapper;
import ms.shop.entity.Banner;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.ResultType;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
public interface BannerDAO extends MsMapper<Banner> {

    /**
     * 查询banner列表
     * @param name
     * @param type
     * @param url
     * @return
     */
    @Select("<script>"
            + "select * from t_banner "
            + "where 1=1 "
            + "<if test=\"name != null and  name!= '' \"> and name like '%${name}%' </if> "
            + "<if test=\"type != 0 \"> and type=#{type} and status=1 </if> "
            + "<if test=\"url != null and  name!= '' \"> and url=#{url} </if> "
            + "order by create_time desc" + "</script>")
    @ResultType(Banner.class)
    List<Banner> queryBanners(@Param("name") String name, @Param("type") Integer type, @Param("url") String url);
}
